<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
    <!-- <script>

        /* var xiaoming={
            name:'小明',
            birth:2001,
            age:function(){
                var year=new Date().getFullYear(); //返回一个年份
                return year-this.birth;
            }
        }

        console.log(xiaoming.age()); */ //20岁
    
        function getAge(){
            var year=new Date().getFullYear()
            return year-this.birth;
        }

        var xiaoming={
            name:'小明',
            birth:2001,
            age:getAge
        }
        console.log(xiaoming.age());//正确的结果 20
        console.log(getAge()); //NAN

    </script> -->

  
</body>
</html>